package com.druid.controller;

import com.druid.entity.User;
import com.druid.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Le-Le on 2017/6/20.
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserRepository userRepository;

    @GetMapping("/list")
    public List<User> findAll() {
        return userRepository.findAll();
    }

    @GetMapping("/save")
    public User save(){
        User user = new User();
        user.setUsername("lishi");
        user.setPassword("zhangsan");
        int i = 1/0;
        return userRepository.save(user);
    }
}
